#include "../head/ddmsform.h"
#include "ui_ddmsform.h"
#include <QtCore/QDir>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>
#include <QtCharts>
#include <QtCharts/QChartView>
#include <QtCharts/QChart>
#include <QtCharts/QLegend>
#include <QtCharts/QPieSeries>
#include <QtCharts/QPieSlice>
#include <QtCore/QTime>
#include <QtWidgets/QGridLayout>
#include <QtCharts/QScatterSeries>


enum eStackedWidgetID{E_GF = 0,E_PL,E_RF,E_DA};


DdmsForm::DdmsForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DdmsForm)
{
    ui->setupUi(this);

    this->setWindowTitle("导向钻进管理系统DDMS");
    //  加载页面
    createTabNav();

//    ui->pushButton
}

DdmsForm::~DdmsForm()
{
    delete ui;
}

void DdmsForm::createTabNav()
{
    resetBtnStyle();
    ui->pushButton->setStyleSheet("QPushButton{color: rgb(255, 255, 255);background-color: rgb(48, 190, 255);}");

    //主控界面
    ui->stackedWidget->insertWidget(E_GF,wpl);
    //设计曲线;
    ui->stackedWidget->insertWidget(E_PL,pl);
    //记录界面
    ui->stackedWidget->insertWidget(E_RF,rf);

    ui->stackedWidget->setCurrentIndex(E_GF);


}




//设置 窗体主题
void DdmsForm::updateUI(int theme)
{
    QPalette pal = window()->palette();
    if (theme == QChart::ChartThemeLight) {
        pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
        pal.setColor(QPalette::WindowText, QRgb(0x404044));
    } else if (theme == QChart::ChartThemeDark) {
        pal.setColor(QPalette::Window, QRgb(0x121218));
        pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
    } else if (theme == QChart::ChartThemeBlueCerulean) {
        pal.setColor(QPalette::Window, QRgb(0x40434a));
        pal.setColor(QPalette::WindowText, QRgb(0xd6d6d6));
    } else if (theme == QChart::ChartThemeBrownSand) {
        pal.setColor(QPalette::Window, QRgb(0x9e8965));
        pal.setColor(QPalette::WindowText, QRgb(0x404044));
    } else if (theme == QChart::ChartThemeBlueNcs) {
        pal.setColor(QPalette::Window, QRgb(0x018bba));
        pal.setColor(QPalette::WindowText, QRgb(0x404044));
    } else if (theme == QChart::ChartThemeHighContrast) {
        pal.setColor(QPalette::Window, QRgb(0xffab03));
        pal.setColor(QPalette::WindowText, QRgb(0x181818));
    } else if (theme == QChart::ChartThemeBlueIcy) {
        pal.setColor(QPalette::Window, QRgb(0xcee7f0));
        pal.setColor(QPalette::WindowText, QRgb(0x404044));
    } else {
        pal.setColor(QPalette::Window, QRgb(0xf0f0f0));
        pal.setColor(QPalette::WindowText, QRgb(0x404044));
    }
    window()->setPalette(pal);
}



//重置按钮样式
void DdmsForm::resetBtnStyle(){
    ui->pushButton->setStyleSheet("QPushButton{"
                                  "color:rgb(0, 0, 0)"
                                  "border: 1px solid rgb(178, 34, 34);background-color: rgb(216, 216, 216);"
                                  "}");
    ui->pushButton_2->setStyleSheet("QPushButton{"
                                  "color:rgb(0, 0, 0)"
                                  "border: 1px solid rgb(178, 34, 34);background-color: rgb(216, 216, 216);"
                                  "}");
    ui->pushButton_3->setStyleSheet("QPushButton{"
                                  "color:rgb(0, 0, 0)"
                                  "border: 1px solid rgb(178, 34, 34);background-color: rgb(216, 216, 216);"
                                  "}");


}

//主控窗口
void DdmsForm::on_pushButton_clicked()
{
    resetBtnStyle();
    ui->pushButton->setStyleSheet("QPushButton{color: rgb(255, 255, 255);background-color: rgb(48, 190, 255);}");

    ui->stackedWidget->setCurrentIndex(E_GF);
}

//数据记录界面
void DdmsForm::on_pushButton_2_clicked()
{
    resetBtnStyle();
    ui->pushButton_2->setStyleSheet("QPushButton{color: rgb(255, 255, 255);background-color: rgb(48, 190, 255);}");
    ui->stackedWidget->setCurrentIndex(E_RF);
}

// 设计曲线窗口
void DdmsForm::on_pushButton_3_clicked()
{
    resetBtnStyle();
    ui->pushButton_3->setStyleSheet("QPushButton{color: rgb(255, 255, 255);background-color: rgb(48, 190, 255);}");
    pl->initDataList();
    ui->stackedWidget->setCurrentIndex(E_PL);
}

// 设计曲线窗口
void DdmsForm::on_pushButton_4_clicked()
{
    resetBtnStyle();
   // ui->pushButton_4->setStyleSheet("QPushButton{color: rgb(255, 255, 255);background-color: rgb(48, 190, 255);}");
    ui->stackedWidget->setCurrentIndex(E_PL);
}

//关闭窗口回到导航界面
 void DdmsForm::closeEvent(QCloseEvent *e)
 {   

     //e->ParentChange();

 }
